package com.brayan.webapp.model.general.i18n;

import java.util.Collection;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.TableGenerator;

import com.brayan.webapp.model.RootEntity;

/**
 * Text that can appear anywhere in this App. And can be translated.
 * 
 * @author Brayan
 * 
 */
@Entity
public class Text extends RootEntity {

	private static final long serialVersionUID = -7242523899251095385L;

	@Id
	@TableGenerator(initialValue = 1000, name = "TextTableGen")
	@GeneratedValue(strategy = GenerationType.AUTO, generator = "TextTableGen")
	private Long id;

	@Column(unique=true)
	private String token;

	/**
	 * Holds the translation that fits to this token.
	 */
	@OneToMany(mappedBy = "textUnit", cascade = CascadeType.ALL, fetch=FetchType.EAGER)
	private Collection<Translation> translation;

	@Column
	private String defaultText;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getToken() {
		return token;
	}

	public void setToken(String token) {
		this.token = token;
	}

	public Collection<Translation> getTranslation() {
		return translation;
	}

	public void setTranslation(Collection<Translation> translation) {
		this.translation = translation;
	}

	public String getDefaultText() {
		return defaultText;
	}

	public void setDefaultText(String defaultText) {
		this.defaultText = defaultText;
	}

}